import { ajax } from '../http.js';

const addressDefaultUrl = '/authc/address/find_by_default';
const predictOrderUrl = '/authc/cart/predict_create_order';
const postageByCartUrl = '/authc/postage/calculate_postage_by_cart';
const creatOrderBycartUrl = '/authc/order/create_by_cart';
const getpostageUrl = '/authc/postage/calculate_postage';
const creatOrderUrl = '/authc/order/create_order';
const payInfoUrl = '/authc/order_pay/pay_info';
const hasPasswordUrl = '/authc/user_rank_check/validate_pay_password';
const gotoPayUrl = '/authc/order_pay/pay';
const checkPayUrl = '/authc/order_pay/check_pay';



const addressDefault = (data, success, fail) => // 查询默认收获地址
  ajax({
    url: addressDefaultUrl,
    data: data,
    success: success,
    fail: fail
  });

const predictOrder = (data, success, fail) => // 根据购物车预生成订单
  ajax({
    url: predictOrderUrl,
    data: data,
    success: success,
    fail: fail
  });

const postageByCart = (data, success, fail) => // 购物车批量结算的邮费和折扣
  ajax({
    url: postageByCartUrl,
    data: data,
    success: success,
    fail: fail
  });
const getpostage = (data, success, fail) => // 单个结算的邮费和折扣
  ajax({
    url: getpostageUrl,
    data: data,
    success: success,
    fail: fail
  });
const creatOrderBycart = (data, success, fail) => // 购物车批量下单
  ajax({
    url: creatOrderBycartUrl,
    data: data,
    success: success,
    fail: fail
  });
const creatOrder = (data, success, fail) => // 单个商品下单
  ajax({
    url: creatOrderUrl,
    data: data,
    success: success,
    fail: fail
  });
const payInfo = (data, success, fail) => // 获取支付订单信息
  ajax({
    url: payInfoUrl,
    data: data,
    success: success,
    fail: fail
  });

const hasPassword = (data, success, fail) => // 校验是否设置支付密码
  ajax({
    url: hasPasswordUrl,
    data: data,
    success: success,
    fail: fail
  });

const gotoPay = (data, success, fail) => // 支付
  ajax({
    url: gotoPayUrl,
    data: data,
    success: success,
    fail: fail
  });

const checkPay = (data, success, fail) => // 查询支付的状态
  ajax({
    url: checkPayUrl,
    data: data,
    success: success,
    fail: fail
  });

export {
  addressDefault,
  predictOrder,
  postageByCart,
  creatOrderBycart,
  getpostage,
  creatOrder,
  payInfo,
  hasPassword,
  gotoPay,
  checkPay
}